package com.bestcem.xm.ticket.enums;

import lombok.Getter;
import lombok.ToString;

/**
 * 跟进人的选择方式
 *
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/17 20:23
 */
@Getter
@ToString
public enum FollowerFilterEnum {

    /**
     * 按 层级/组织+角色 选择跟进人
     */
    REGION(0, "REGION"),

    /**
     * 按用户选择跟进人
     */
    USER(1, "USER");

    private final String name;

    private final Integer index;

    FollowerFilterEnum(Integer index, String name) {
        this.name = name;
        this.index = index;
    }

    /**
     * 根据 index 获取枚举实体
     * 找不到则默认返回 REGION
     *
     * @param index 枚举index
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2021/8/17 20:31
     */
    public static FollowerFilterEnum getByIndex(Integer index) {
        for (FollowerFilterEnum value : values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        return REGION;
    }
}
